﻿using Excel2DbTool.Helpers;
using Excel2DbTool.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Excel2DbTool.Common
{
    public abstract class SqlHelper
    {
        //最终还是决定又ConfigHelper直接提供
        //protected static readonly String ConnectStr = ConfigHelper.DbConnectStr;
        //protected static readonly String TableName = ConfigHelper.TableName;


        public static SqlHelper GetInstance()
        {
            switch (ConfigHelper.DbType) //"ORACLE"
            {
                case "ORACLE":
                    return OracleHelper.Instance;
                //case "SQLSERVER":
                //    return new SQLServerHelper();
                //case "MYSQL":
                //    return new MySQLSqlHelper();
                default:
                    throw new NotImplementedException("未实现的数据库类型");
            }
        }


        public abstract void InsertRecord(ExcelRowRecord excelRR);
        public abstract void BatchInsertRecord(IEnumerable<ExcelRowRecord> excelRRs);

        public abstract DataTable Select(string querySqlStr);
        public abstract void Insert(String inserSqlStr);
        public abstract int GetTotalRowCountInTable(string tableName);


        public abstract void CreateTable();
        public abstract void DumpTable();
        public abstract void ClearTable(string tableName);
        public abstract T GetStatisticVal<T>(string sql);
        //public abstract void CreateTable(string tableName);
        //public abstract void DumpTable(string tableName);
    }
}
